﻿using WorkSummary.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WorkSummary.Bussiness.Bll;
using System.Web.SessionState;

namespace WorkSummaryReoprter.ashx
{
    /// <summary>
    /// login 的摘要说明
    /// </summary>
    public class login : IHttpHandler, IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var action = context.Request["action"];
            switch (action)
            {
                case "login":
                    var AccountNum = context.Request["user"];
                    var password = context.Request["passwd"];
                    //context.Response.Write(JSONhelper.ToJson(BUser.Instance.UserLogin2(AccountNum, password)));
                    context.Response.Write(JSONhelper.ToJson(BUser.Instance.LoginSys(AccountNum, password)));
                    break;
                case "logout":
                    context.Response.Write(JSONhelper.ToJson(BUser.Instance.LogOut()));
                    break;
                default:
                    context.Response.Write(JSONhelper.ToJson(new { code = -1, msg = "no action matched！" }));
                    break;
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}